package persistencia;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;

import bean.PEWSOperation;
import bean.PEWSOperations;
import bean.PortType;
import bean.WSDLOperation;

public class Comparador {
	private Hashtable<Integer, PEWSOperation> hstXPEWS;
	private Hashtable<String, WSDLOperation> hstWSDL;
	private ArrayList<Hashtable<String, WSDLOperation>> hstsWSDL;
	private int con = 0;
	
	public Comparador(){
		hstXPEWS = new Hashtable<Integer, PEWSOperation>();
		hstWSDL = new Hashtable<String, WSDLOperation>();
		hstsWSDL = new ArrayList<Hashtable<String, WSDLOperation>>();
	}
	
	public void inserirWSDLNaHash(PortType portType){  
		for(int i = 0; i < portType.getOperations().size(); i++){
			hstWSDL.put(portType.getOperations().get(i).getName(), portType.getOperations().get(i));
			hstsWSDL.add(hstWSDL);
		}
	}
	
	public void inserirXPEWSNaHash(PEWSOperations pewsOps){
		for(int i = 0; i < pewsOps.getPewsOperations().size(); i++)
			hstXPEWS.put(con++, pewsOps.getPewsOperations().get(i));
	}
	
	public void comparar(Hashtable<String, WSDLOperation> ahstWSDL){
		for(Enumeration<PEWSOperation> eHST = hstXPEWS.elements(); eHST.hasMoreElements();){
			PEWSOperation opName = eHST.nextElement();
			if(ahstWSDL.containsKey(opName.getName()))
				System.out.printf("%s\n", opName.getName());
		}
	}
	
	public void comparar(ArrayList<Hashtable<String, WSDLOperation>> ahstsWSDL){
		for(int i = 0; i < ahstsWSDL.size(); i++){
			for(Enumeration<PEWSOperation> eHST = hstXPEWS.elements(); eHST.hasMoreElements();){
				PEWSOperation opName = eHST.nextElement();
				if(ahstsWSDL.get(i).containsKey(opName))
					System.out.printf("%s\n", opName);
			}
		}
	}
	
	public Hashtable<Integer, PEWSOperation> getXpews() {
		return hstXPEWS;
	}

	public void setXpews(Hashtable<Integer, PEWSOperation> hstXPEWS) {
		this.hstXPEWS = hstXPEWS;
	}

	public Hashtable<String, WSDLOperation> getHstWSDL() {
		return hstWSDL;
	}

	public void setHstWSDL(Hashtable<String, WSDLOperation> hstWSDL) {
		this.hstWSDL = hstWSDL;
	}
	
	public ArrayList<Hashtable<String, WSDLOperation>> getHstsWSDL() {
		return hstsWSDL;
	}

	public void setHstWSDL(ArrayList<Hashtable<String, WSDLOperation>> hstsWSDL) {
		this.hstsWSDL = hstsWSDL;
	}
}
